# demo02_tuple.py
tuple01 = (10, 1.23, "hehe", True, 1.23)
print(tuple01, type(tuple01))  # <class 'tuple'>
print(tuple01[0], tuple01[-1])  # 10 1.23
print(tuple01[:3])  # (10, 1.23, 'hehe')
print(len(tuple01), tuple01.count(10))  # 5 1
print(10 in tuple01, 11 not in tuple01)
# 注意: 存放单个元素的元组需要在元素后加逗号
tuple02 = (10)
print(tuple02, type(tuple02))  # 10 <class 'int'>
tuple03 = (10,)  # (10,) <class 'tuple'>
print(tuple03, type(tuple03))
# tuple03[0] = "hehe"
# TypeError: 'tuple' object does
#             not support item assignment